import request from '@/utils/request'

export interface AccountConfigDTO {
  configId?: string
  billType: string // PO_IN/SO_OUT
  entryType: string // STOCK/PAYABLE/RECEIVABLE/REVENUE/COST/TAX_IN/TAX_OUT
  accountId: string
  dcFlag: string // DEBIT/CREDIT
  priority?: number
  status?: number
  remark?: string
}

export function pageAccountConfig(params: { pageNum?: number; pageSize?: number; billType?: string; entryType?: string }) {
  return request({ url: '/erp/account/config/page', method: 'get', params })
}

export function listAccountConfig(params?: { billType?: string }) {
  return request({ url: '/erp/account/config/list', method: 'get', params })
}

export function getAccountConfig(id: string) {
  return request({ url: `/erp/account/config/${id}`, method: 'get' })
}

export function getConfig(billType: string, entryType: string) {
  return request({ url: '/erp/account/config/get', method: 'get', params: { billType, entryType } })
}

export function createAccountConfig(data: AccountConfigDTO) {
  return request({ url: '/erp/account/config', method: 'post', data })
}

export function updateAccountConfig(id: string, data: AccountConfigDTO) {
  return request({ url: `/erp/account/config/${String(id)}`, method: 'put', data })
}

export function deleteAccountConfig(id: string) {
  return request({ url: `/erp/account/config/${String(id)}`, method: 'delete' })
}

